package org.xx.armory.spring5.junit;

import static org.xx.armory.commons.Validators.rejectIfBlank;

public class PostgresDbUnitHelper
        extends DbUnitHelper {
    @Override
    protected void resetSequenceValue(
            String name,
            int value
    ) {
        this.jdbcTemplate.execute("DROP SEQUENCE " + escapeIdentifier(name));
        this.jdbcTemplate.execute("CREATE SEQUENCE " + escapeIdentifier(name) + " MINVALUE 0 START WITH " + value);
    }

    @Override
    protected String escapeIdentifier(
            String identifier
    ) {
        return rejectIfBlank(identifier, "identifier").trim().toLowerCase();
    }
}
